﻿#ifndef NSSHARE_SYS_ASYNC_DIRECTORY_RESULT_H_
#define NSSHARE_SYS_ASYNC_DIRECTORY_RESULT_H_

#include "utils/event_delegate.h"
#include "utils/event_adapter.h"
#include "async_event_args.h"
#include "directory_define.h"

namespace nsshare
{
namespace sys
{

class Event;
class DirectoryAsyncEventArgs;

typedef utils::EventDelegate<DirectoryAsyncEventArgs&> DirectoryAsyncEventDelegate;
typedef utils::EventHandler<DirectoryAsyncEventArgs&>  DirectoryAsyncEventHandler;

class DirectoryAsyncEventArgs : public AsyncEventArgs
{
public:
    DirectoryAsyncEventArgs();
    DirectoryAsyncEventArgs(Event & e);

    void SetBuffer(void * data, size_t count);

    void set_option(ReadDirectoryChangesOption::Value option);
    void set_completion_delegate(DirectoryAsyncEventHandler * handler);

    void * data() const;
    size_t count() const;
    uint32_t error() const;
    uint32_t transfered() const;
    ReadDirectoryChangesOption::Value option() const;

private:
    void OnCompleted(uint32_t error, uint32_t transfered);
private:
    void * data_;
    size_t count_;
    uint32_t error_;
    uint32_t transfered_;
    ReadDirectoryChangesOption::Value option_;
    DirectoryAsyncEventDelegate completion_delegate_;

    friend class Directory;
    friend class DirectoryRoutines;
};

}
}

#endif